﻿#include "xregister_p.h"

XRegisterPrivate::XRegisterPrivate()
    : deviceType(PLC),
      deviceNumber(1),
      objectType(D),
      objectNumber(0),
      valueType(Word),
      registerValue(0)
{

}

XRegisterPrivate::~XRegisterPrivate()
{

}

XRegister::XRegister(QObject *parent)
    : QObject(parent),
      xRegisterP(new XRegisterPrivate)
{

}

XRegister::~XRegister()
{
    delete xRegisterP;
}

/*!
    \property XRegister::deviceType
    \brief the type of the device

    The default deviceType is PLC.

    \sa indent
*/
DeviceType XRegister::getDeviceType() const
{
    return xRegisterP->deviceType;
}

void XRegister::setDeviceType(DeviceType type)
{
    if(xRegisterP->deviceType == type)
        return;
    xRegisterP->deviceType = type;
}

/*!
    \property XRegister::deviceNumber
    \brief the number of the device

    The default deviceNumber is 1.

    \sa indent
*/
int XRegister::getDeviceNumber() const
{
    return xRegisterP->deviceNumber;
}

void XRegister::setDeviceNumber(int num)
{
    if(xRegisterP->deviceNumber == num)
        return;
    xRegisterP->deviceNumber = num;
}

/*!
    \property XRegister::objectType
    \brief the type of the object

    The default objectType is X.

    \sa indent
*/
RegistersObjectType XRegister::getObjectType() const
{
    return xRegisterP->objectType;
}

void XRegister::setObjectType(RegistersObjectType type)
{
    if(xRegisterP->objectType == type)
        return;
    xRegisterP->objectType = type;
}

/*!
    \property XRegister::objectNumber
    \brief the number of the object

    The default objectNumber is 0.

    \sa indent
*/
int XRegister::getObjectNumber() const
{
    return xRegisterP->objectNumber;
}

void XRegister::setObjectNumber(int num)
{
    if(xRegisterP->objectNumber == num)
        return;
    xRegisterP->objectNumber = num;
}

/*!
    \property XRegister::valueType
    \brief the type of the value

    The default valueType is Word.

    \sa indent
*/
ValueType XRegister::getValueType() const
{
    return xRegisterP->valueType;
}

void XRegister::setValueType(ValueType type)
{
    if(xRegisterP->valueType == type)
        return;
    xRegisterP->valueType = type;
}

/*!
    \property XRegister::registerValue
    \brief the value of the register

    \sa indent
*/
double XRegister::getRegisterValue() const
{
    return xRegisterP->registerValue;
}

void XRegister::setRegisterValue(double value)
{
    if(xRegisterP->registerValue == value)
        return;

    xRegisterP->registerValue = value;
}
